/*
 * Copyright 2002 Christopher L. Conway, Cheng-Hong Li and Megan Pengelly.
 *
 * This file is part of The Pencil Compiler.
 *
 * The Pencil Compiler is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The Pencil Compiler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with The Pencil Compiler; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* @author Megan Pengelly */
package math.petrinets.model;

import java.util.HashSet ;
import java.awt.Point;

import com.mxgraph.model.mxCell;

public abstract class Transition{
	private HashSet in;
	private HashSet out ;
	private boolean immediate ;
	private String name ;
	private Point coord;
	
	private int position;
	private int processTime;
	
	private mxCell cell;
	private double heuristic;

	public Transition() {
		immediate = true ;
		in = new HashSet() ;
		out = new HashSet() ;
		coord = new Point();
	}

	public abstract void onFire() ;

	public void addIn(Place p) {
		addIn(p,1) ;
	}

	public void addIn(Place p, int weight) {
		synchronized(in) {
			in.add(new Arc(p,weight)) ;
		}
	}

	public void addOut(Place p) {
		addOut(p,1) ;
	}

	public void addOut(Place p, int weight) {
		synchronized(out) {
			out.add(new Arc(p,weight)) ;
		}
	}
	
	public HashSet getIn(){
		return in;
	}
	
	public HashSet getOut(){
		return out;
	}

	public void setImmediate(boolean imm) {
		this.immediate = imm ;
	}

	public boolean isImmediate() {
		return immediate;
	}

	public void setName(String name) {
		this.name = name ;
	}

	public String getName() {
		return name;
	}

	public void setCoord(int x, int y) {
		coord.setLocation(x,y);
	}
	
	public Point getCoord() {
		return coord;
	}
	
	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}

	public int getProcessTime() {
		return processTime;
	}

	public void setProcessTime(int processTime) {
		this.processTime = processTime;
	}

	public void setCell(Object cell) {
		this.cell = (mxCell) cell;
	}
	
	public mxCell getCell() {
		return cell;
	}

	public double getHeuristic() {
		// TODO Auto-generated method stub
		return heuristic;
	}
	
	public void setHeuristic(double h) {
		heuristic = h;
	}
}

